import Axios from 'axios';
import * as constants from './constants'

const changeLogin = () => ({
  type: constants.CHANGE_LOGIN,
  value: true
})

export const login = (accout, password) => {
  return dispatch => {
    Axios.get(`/api/login.json?accout=${accout}&password=${password}`).then(res => {
       const result = res.data.data;
       if (result) {
        dispatch(changeLogin())
       } else {
         console.log('登录失败')
       }
    })
  }
}

export const logout = () => ({
  type: constants.CHANGE_LOGOUT,
  value: false
})
